Skip to content

Ground the OAuth metadata doc types in the SDK's - #524

Merged
alistair3149 merged 2 commits into
masterfrom
sdk-oauth-doc-types
Jul 30, 2026
Merged

Ground the OAuth metadata doc types in the SDK's#524
alistair3149 merged 2 commits into
masterfrom
sdk-oauth-doc-types

Conversation

@alistair3149

@alistair3149 alistair3149 commented Jul 30, 2026

Copy link
Copy Markdown
Member

Replaces the hand-declared ProtectedResourceDoc (RFC 9728) and AsMetadataDoc (RFC 8414) interfaces with aliases of the SDK's OAuthProtectedResourceMetadata and OAuthMetadata types, narrowed with Required<Pick<…>> to the fields this server always emits. Field names and shapes can no longer drift from the spec schemas, and a renamed SDK field becomes a compile error here. Types only — the emitted documents are unchanged, and no new dependency is added (both types are exported by @modelcontextprotocol/server).

One trade-off to weigh: the SDK schemas are loose objects, so the aliases carry a [k: string]: unknown index signature and a typo'd key in a builder literal is no longer an excess-property compile error. The per-field unit tests on both builders still catch a typo in any currently-emitted field at runtime.

TokenResponse deliberately stays local: our parser enforces expires_in and tolerates a missing token_type, which is the inverse of the SDK's OAuthTokens contract on both fields, so adopting it would misstate what the code validates.

Verified: full suite and typecheck green; a fixed-input smoke script confirmed the emitted documents are byte-identical between this branch's build and a master-equivalent build.

🤖 Generated with Claude Code

alistair3149 and others added 2 commits July 30, 2026 14:40
ProtectedResourceDoc and AsMetadataDoc were hand-declared alongside the
SDK's RFC 9728 and RFC 8414 types. Alias them to the SDK types instead,
narrowed to the fields this server always emits, so the field names and
shapes cannot drift from the spec schemas. TokenResponse stays local on
purpose: it encodes what our parser actually enforces (expires_in
required, token_type tolerated absent), which is the inverse of the
SDK's OAuthTokens contract.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Name all six narrowed AS-metadata fields' advertisements, and fence off
the plausible swap of TokenResponse for the SDK's OAuthTokens, whose
contract is the inverse of what post() enforces.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@alistair3149
alistair3149 marked this pull request as ready for review July 30, 2026 18:56
@alistair3149
alistair3149 merged commit 73a6d95 into master Jul 30, 2026
1 check passed
@alistair3149
alistair3149 deleted the sdk-oauth-doc-types branch July 30, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant